USE [ServerMonitor]
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[AddServer]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[AddServer]
GO
USE [ServerMonitor]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE [dbo].[AddServer] 
@Name NVARCHAR(256), 
@Instance NVARCHAR(256),
@IP VARCHAR(50),
@UserName NVARCHAR(256) = NULL,
@Password NVARCHAR(256) = NULL
AS
BEGIN
  DECLARE @Key NVARCHAR(256) = 'lenovo,2008'
  INSERT INTO [ServerMonitor].[dbo].[Server]
  ([Name],[Instance],[IP],[UserName],[Password])
  VALUES(@Name,@Instance,@IP,
  EncryptByPassPhrase(@Key,@UserName),
  EncryptByPassPhrase(@Key,@Password))
END

GO


